//
//  QingQiuShuJu.m
//  XiangMu
//
//  Created by 康世标 on 15/7/21.
//  Copyright (c) 2015年 康世标. All rights reserved.
//

#import "QingQiuShuJu.h"

@implementation QingQiuShuJu

+ (void)DengLu:(NSString*)iphoen Psw:(NSString *)psw HuiChuan:(UeserInfo)block;
{
    
    AFHTTPRequestOperationManager*manager=[AFHTTPRequestOperationManager manager];    NSLog(@"-psw3-%@",[psw MD5]);

    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_DENGLU]parameters:@{@"phoneNum":iphoen,@"password":[psw MD5]} success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        
        if (block) {
            
            block(responseObject,YES);
            
        }
    
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        block(nil,NO);
        
    }];
    
}
+(void)YiYuanPeiHu:(YiYuanBlock)blcok{
    
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    
    NSMutableArray *zongArr= [[NSMutableArray alloc]initWithCapacity:0];
    NSMutableArray *xiaoArr1=[[NSMutableArray alloc]initWithCapacity:0];
    NSMutableArray *xiaoArr2=[[NSMutableArray alloc]initWithCapacity:0];
    NSMutableArray *xiaoArr3=[[NSMutableArray alloc]initWithCapacity:0];
    [manager GET:[NSString stringWithFormat:@"%@%@",URL,URL_YIYUANPEIHU] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        
        NSArray*carerTypes=[responseObject objectForKey:@"carerTypes"];
        NSArray*decadeTypes=[responseObject objectForKey:@"decadeTypes"];
        NSArray*weightTypes=[responseObject objectForKey:@"weightTypes"];
        
        [carerTypes enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
            YiYuanPeiHuShuJu *y=[[YiYuanPeiHuShuJu alloc]initWithDictyion:obj];
            
            [xiaoArr1 addObject:y];
            
            
        }];
        [decadeTypes enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
            YiYuanPeiHuShuJu *y=[[YiYuanPeiHuShuJu alloc]initWithDictyion:obj];
            
            [xiaoArr2 addObject:y];
            
            
        }];
        [weightTypes enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
            YiYuanPeiHuShuJu *y=[[YiYuanPeiHuShuJu alloc]initWithDictyion:obj];
            
            [xiaoArr3 addObject:y];
            
            
        }];
        [zongArr addObject:xiaoArr1];
        [zongArr addObject:xiaoArr2];
        [zongArr addObject:xiaoArr3];
        
        blcok(zongArr,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        blcok(zongArr,NO);
        
    }];
    
}
+(void)SheQuDeLaoRenPeiHu:(YiYuanBlock)block1{
    
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    
    NSMutableArray *zongArr= [[NSMutableArray alloc]initWithCapacity:0];
    NSMutableArray *xiaoArr1=[[NSMutableArray alloc]initWithCapacity:0];
    NSMutableArray *xiaoArr2=[[NSMutableArray alloc]initWithCapacity:0];
    NSMutableArray *xiaoArr3=[[NSMutableArray alloc]initWithCapacity:0];
    [manager GET:[NSString stringWithFormat:@"%@%@",URL,URL_YIYUANPEIHU] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
     {

         NSArray*carerTypes=[responseObject objectForKey:@"carerTypes"];
         NSArray*decadeTypes=[responseObject objectForKey:@"decadeTypes"];
         NSArray*xingBie=@[@{@"type":@"男"},@{@"type":@"女"}];
         
         [carerTypes enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
             YiYuanPeiHuShuJu *y=[[YiYuanPeiHuShuJu alloc]initWithDictyion:obj];
             
             [xiaoArr1 addObject:y];

         }];
         [decadeTypes enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
             YiYuanPeiHuShuJu *y=[[YiYuanPeiHuShuJu alloc]initWithDictyion:obj];
             
             [xiaoArr2 addObject:y];
             
         }];
         [xingBie enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
             YiYuanPeiHuShuJu *y=[[YiYuanPeiHuShuJu alloc]initWithDictyion:obj];
             
             [xiaoArr3 addObject:y];
          }];

         [zongArr addObject:xiaoArr1];
         [zongArr addObject:xiaoArr2];
         [zongArr addObject:xiaoArr3];

         
         block1(zongArr,YES);
         
         
     } failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {
         block1(zongArr,NO);
         
     }];

}
+ (void)HuoQuHongGong:(NSDictionary *)dic1 HuGong:(YiYuanBlock)blick{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    NSMutableDictionary*dic=[[NSMutableDictionary alloc]initWithCapacity:0];
    [dic setObject:dic1 [@"city"] forKey:@"city"];
    [dic setObject:@([dic1 [@"carerType"] intValue])forKey:@"carerType"];
    [dic setObject:@([dic1 [@"weightType"] intValue]) forKey:@"weightType"];
    [dic setObject:@([dic1 [@"price"] intValue]) forKey:@"price"];
    [dic setObject:@([dic1 [@"age"] intValue]) forKey:@"age"];
    [dic setObject:@([dic1 [@"sex"] intValue]) forKey:@"sex"];
    [dic setObject:@([dic1 [@"state"] intValue]) forKey:@"state"];
    [dic setObject:@([dic1 [@"page"] intValue]) forKey:@"page"];
    [dic setObject:@([dic1 [@"rows"] intValue]) forKey:@"rows"];
    
    [dic setObject:[dic1 valueForKey:@"lat"]  forKey:@"lat"];
    [dic setObject:[dic1 valueForKey:@"lng"]  forKey:@"lng"];

    
    [dic setObject:@([dic1 [@"other"] integerValue]) forKey:@"other"];
    
    [dic setObject:[dic1 valueForKey:@"type"] forKey:@"type"];
    
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_HUOQUHUGONG] parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject)
     {
         blick(responseObject,YES);
         
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {
            blick(nil,NO);
    }];
    
}
+ (void) HuoQuYanZhengMa:(NSString *)iphone url:(NSString *)url Hui:(YanZhengMg )block{
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    [manager GET:[NSString stringWithFormat:@"%@%@?phoneNum=%@",URL,url,iphone] parameters:@"" success:^(NSURLSessionDataTask *task, id responseObject)
    {

        if ([[responseObject valueForKey:@"status"] intValue]==200)
        {
            
            
            
            block([responseObject valueForKey:@"msg"],YES);
        }

        else
        {
            block([responseObject valueForKey:@"msg"],NO);
        }
        
        
        
    } failure:^(NSURLSessionDataTask *task, NSError *error)
    {
        block(@"网络链接超时",NO);
    }];
}
+ (void)ZhuCe:(NSString *)iphone YanZhengMa:(NSString *)yan PsW:(NSString *)psw url:(NSString *)url HuiChuan:(YanZhengMg)block{
    
    NSString * ps =nil;
    
    if ([url isEqualToString:@"/user/modify/psw"]) {
        
        ps = @"psw";
    }
    else{
        
        ps = @"password";
    }
    
    AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];
    [manger POST:[NSString stringWithFormat:@"%@%@",URL,url] parameters:@{@"phoneNum":iphone,ps:[psw MD5],@"checkCode":@([yan intValue])} success:^(NSURLSessionDataTask *task, id responseObject) {
        
        
        if ([[responseObject valueForKey:@"status"] intValue]==200) {
            
          
            block([responseObject valueForKey:@"msg"],YES);
        }
        else if ([[responseObject valueForKey:@"status"] intValue]==202)
        {
            
            block([responseObject valueForKey:@"msg"],NO);
        }
        else{
            block([responseObject valueForKey:@"msg"],NO);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error)
    {
         block(@"网络链接超时",NO);
    }];
}
+ (void)ShouYeImagView:(NSString *)type HuiChuan:(YiYuanBlock)block{
    
    AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];
    

    [manager GET:[NSString stringWithFormat:@"%@%@/%@",URL,URL_SHOUYETUPIAN,type] parameters:@"" success:^(NSURLSessionDataTask *task, id responseObject)
    {

        
        if ([[responseObject objectForKey:@"status"] intValue]==200) {
            
            if (block) {
                
                block([responseObject valueForKey:@"data"],YES);
            }
            
        }
        else{
            block (responseObject,NO);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        block(nil,NO);
    }];
    
}
+ (void)HuoQuQuanBuFenXiang:(NSDictionary *)dic HuiChuan:(YiYuanBlock)block{
    
    AFHTTPSessionManager * manager =[AFHTTPSessionManager manager];
    NSString *str=[NSString stringWithFormat:@"%@%@?city=杭州&page=%d&rows=%d",URL,URL_QUANBUFENXIANGXINXI,[[dic valueForKey:@"page"] intValue],[[dic valueForKey:@"rows"] intValue]];
   
    NSString * url = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    


    [manager GET:url parameters:@"" success:^(NSURLSessionDataTask *task, id responseObject)
    {
        if ([[responseObject  valueForKey:@"status"] intValue]==200) {
         
            block(responseObject,YES);
        }
        else{
            
            block(responseObject,NO);
            
        }

        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        block(nil,NO);
    }];
}
+ (void)ShaiXuanFenXiang:(NSDictionary *)dic HuiChuan:(YiYuanBlock)block{
    
    AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];
    
    [manager GET:[NSString stringWithFormat:@"%@%@/%d/%d?page=%d&rows=%d",URL,URL_SHAIXUANFENXIANG,[[dic valueForKey:@"type"] intValue],[[dic valueForKey:@"id"] intValue],[[dic valueForKey:@"page"] intValue],[[dic valueForKey:@"rows"] intValue]] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)
    {
        if ([[responseObject valueForKey:@"status"]intValue]==200) {
            
            block (responseObject,YES);
        }
        else{
            
            block (responseObject,NO);
        }
        

        
    } failure:^(NSURLSessionDataTask *task, NSError *error)
    {
        block(nil,NO);
    }];
}
+ (void)HuoQuFaBuShiDeShuJu:(YiYuanBlock)block{
    
    AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];
    
    [manager GET:[NSString stringWithFormat:@"%@%@",URL,URL_HUOQUFABUPEISHU] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)
    {

        block(responseObject,YES);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        block(nil,NO);
    }];
    
}
+ (void)FaBuPeiHu:(NSDictionary *)dic HuiChuan:(YiYuanBlock)block{
    
    AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];
    
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_FABUPEIHU] parameters:dic success:^(NSURLSessionDataTask *task, id responseObject)
    {
        

        block(responseObject,YES);
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
         block(nil,NO);
    }];
}
+ (void)PingLu:(NSDictionary *)dic HuiChuan:(YiYuanBlock)block{
    
    AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];
    

    [manager GET:[NSString stringWithFormat:@"%@%@?shareId=%lld&page=%d&rows=%d",URL,URL_PINGLUN,[[dic valueForKey:@"shareId"] longLongValue],[[dic valueForKey:@"page"] intValue],[[dic valueForKey:@"rows"] intValue]] parameters:nil
     
    success:^(NSURLSessionDataTask *task, id responseObject)
    {

        
        block (responseObject,YES);
        
        
    } failure:^(NSURLSessionDataTask *task, NSError *error)
    {
        block (nil,NO);
    }];
    
}
+ (void)FaBuFenXiang:(NSDictionary *)dic imagView:(NSArray *)arr HuiChuan:(YiYuanBlock)block;{
    __block NSError *error = nil;
    
    NSMutableURLRequest * urlRequest = [[AFHTTPRequestSerializer serializer]multipartFormRequestWithMethod:@"post" URLString:[NSString stringWithFormat:@"%@%@/1",URL,URL_FENXIANGDAITUPIAN] parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        
      for (int i =0;i<arr.count;i++) {
            
              [formData appendPartWithFileData:UIImageJPEGRepresentation([arr objectAtIndex:i], 0.3) name:[NSString stringWithFormat:@"uploadFiles%d.jpg",i] fileName:[NSString stringWithFormat:@"%d.jpg",i] mimeType:@"image/jpeg"];
            }
        
    } error:&error];
    
    if (error) {
        
        NSLog(@"%@",[error description]);
        
        return;
        
    }
    AFHTTPRequestOperation *opetation = [[AFHTTPRequestOperation alloc]initWithRequest:urlRequest];
    
    [opetation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSData *data = (NSData *)responseObject;
        
        NSMutableArray *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        
        
        block(dic,YES);
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
       
        
        block(nil,NO);
        
    }];
    
    [opetation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
        
    }];
    
    [opetation start];


}
+ (void)HuoQuPeiHuPingJia:(NSNumber *)number HuiChuan:(YiYuanBlock)block{
    
    AFHTTPRequestOperationManager * manage = [AFHTTPRequestOperationManager manager];
    
      
    
    [manage GET:[NSString stringWithFormat:@"%@%@%@",URL,URL_HUQUPEIHUSHIPINGJIA,number] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        block(responseObject,YES);
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        
        block(nil,NO);
        
    }];
}
+ (void)ShangChuanImagView:(UIImage *)image ID:(NSNumber *)numberID Block:(UeserInfo )block{
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    

         manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_YONGHUSHANGCHUANTOUXIANG] parameters:@{@"uid":numberID} constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
    {
               
        NSData * data = UIImageJPEGRepresentation(image, 0.3);
        
        [formData appendPartWithFileData:data name:@"uploadFile" fileName:@"uploadFile.jpg" mimeType:@"image/jpeg"];
        
        
    } success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        
        block (responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil,NO);
        
    }];

    
}
+ (void)upDate:(NSNumber *)number Param:(NSString *)param Block:(UeserInfo )block{
    
    
    AFHTTPRequestOperationManager * manager= [AFHTTPRequestOperationManager manager];

    [manager POST:[NSString stringWithFormat:@"%@%@%@",URL,URL_XIUGAIYONGHUXINXI,number] parameters:@{@"id":@(1),@"param":param} success:^(AFHTTPRequestOperation *operation, id responseObject)
    {

        
        block(responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        block(nil,NO);
        
    }];
}
+ (void)getHuLixinxi:(NSNumber *)number carerId:(NSNumber *)carerId Blokc:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];

    
    [manager GET:[NSString stringWithFormat:@"%@%@?carerId=%@&userId=%@",URL,URL_HUOQUHULIXINXI,carerId,number] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block (responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        block (nil,NO);
        
    }];
}
+ (void)FenXiangDianZan:(NSNumber *)userId sheareId:(NSNumber *)shareId Blokc:(UeserInfo )blokc{
    
   NSString * ticket= [[NSUserDefaults standardUserDefaults] objectForKey:@"msg"];
    
    
    AFHTTPRequestOperationManager * manager= [AFHTTPRequestOperationManager manager];
        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_FENXIANGDIANZAN] parameters:@{@"userId":userId,@"shareId":shareId,@"ticket":ticket} success:^(AFHTTPRequestOperation *operation, id responseObject)
    {

        
        blokc(responseObject,YES);
        
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        blokc(nil,NO);
    }];
    
}
+ (void)HuoQuWoDeDingDan:(NSDictionary *)dic Block:(UeserInfo)blcok{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    

    [manager GET:[NSString stringWithFormat:@"%@%@?userId=%@&page=%@&rows=%@",URL,[dic valueForKey:@"url"],[dic valueForKey:@"userId"],[dic valueForKey:@"page"],[dic valueForKey:@"rows"]] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        blcok (responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        blcok (nil,NO);
        
        
    }];
}
//获取我的地址
+ (void)getWoDeDiZhi:(NSNumber *)number BLokc:(UeserInfo)blokc{
    
    AFHTTPRequestOperationManager * manager= [AFHTTPRequestOperationManager manager];
    [manager GET:[NSString stringWithFormat:@"%@%@?userId=%@",URL,URL_HUOQUDIZHI,number] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        blokc(responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        blokc(nil,NO);
    }];
}
//新增地址
+ (void)addDiZhi:(NSDictionary * )dic block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager= [ AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_XINZEDIZHI] parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block(responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block(nil,NO);
    }];
}
+ (void)getWodeShoucang:(NSDictionary * )dic Block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager GET:[NSString stringWithFormat:@"%@%@?userId=%@&page=%@&rows=%@",URL,URL_WODESHOUCANG,[dic valueForKey:@"userId"],[dic valueForKey:@"page"],[dic valueForKey:@"rows"]] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block (responseObject, YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil ,NO);
    }];
}
//优惠劵
+ (void)getWoDeYouHuiJuan:(NSNumber *)number Block:(UeserInfo)block{
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager GET:[NSString stringWithFormat:@"%@%@?userId=%@",URL,URL_YOUHUIJUAN,number] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block (responseObject, YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil ,NO);
    }];

}
+ (void)addPingLu:(NSDictionary *)dic Block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_ADDPINGLU] parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        block(responseObject, YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil ,NO);
    }];
}
//我的订单详情
+ (void)getwoDeDingDanXiangQing:(NSString * )url number:(NSString *)number Block:(UeserInfo)block{
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager GET:[NSString stringWithFormat:@"%@%@?orderId=%@",URL,url,number] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block (responseObject, YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil ,NO);
    }];


}
+ (void)AddPeiHuShiShouCang:(NSNumber *)userId carerId:(NSNumber *)carerId block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_SHOUCANGPEIHUSHI] parameters:@{@"userId":userId,@"carerId":carerId} success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block(responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block(nil,NO);
    }];
}
+  (void)YiJianFanKui:(NSNumber *)userId advice:(NSString *)advice blcok:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * mangager =[AFHTTPRequestOperationManager manager];
    [mangager POST:[NSString stringWithFormat:@"%@%@",URL,URL_YIJIANFANKUI] parameters:@{@"userId":userId,@"advice":advice} success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        block(responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        block(nil, NO);
        
        
    }];
    
}
+ (void)dingDanPingJia:(NSDictionary *)parem blcok:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_DINGDANPINGJIA] parameters:parem success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        block(responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block(nil,NO);
    }];
}
+ (void)tiQianJieShu:(NSDictionary *)parem block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_TIQIANJIESHU] parameters:parem success:^(AFHTTPRequestOperation *operation, id responseObject) {
        block(responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block(nil,NO);
        
    }];
}
+ (void)jieGeChaXun:(NSDictionary *)parem block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_JIAGECHAXUN] parameters:parem success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block(responseObject,YES);
       
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block(nil,NO);
        
    }];
}
+ (void)fuKuan{
    
    AFHTTPRequestOperationManager *manager =[AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@/alipaytest",URL] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        
    
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}
+ (void)chuanJianDingDan:(NSDictionary *)parem block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager *manmager = [AFHTTPRequestOperationManager manager];
    [manmager POST:[NSString stringWithFormat:@"%@%@",URL,URL_CHUANGJIANDINGDAN] parameters:parem success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block(responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block(nil, NO);
        
    }];
}
+ (void)getHuoQuZhiFuXinXI:(NSDictionary *)parameter block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_WXYUZHIDUXINXI] parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        
        block (responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        block (nil,NO);
        
        
    }];
}
+ (void)deleteWithDiZhi:(NSDictionary *)paremeter blcok:(UeserInfo)blcok{
    
    AFHTTPRequestOperationManager *manager= [AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_DELETEDIZHI] parameters:paremeter success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        blcok(responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        blcok(nil,NO);
        
    }];
}
+ (void)weiZhiFuDingDanQuXiao:(NSString *)orderId blcok:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_WEIZHIFUDINGDANQUXIAO] parameters:@{@"orderId":orderId} success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        block (responseObject,YES);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil,NO);
        
    }];
}
+ (void)souSuoShuJu:(NSString *)context block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager= [AFHTTPRequestOperationManager manager];
    
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_SOUSUO] parameters:@{@"city":@"杭州",@"q":context} success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block (responseObject,YES);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        block (nil,NO);
    }];
}
+ (void)zhiFuBao:(UeserInfo)block{
    
//    AFHTTPRequestOperationManager *manager =[AFHTTPRequestOperationManager manager];
//    [manager POST:[NSString stringWithFormat:@"%@/alipaytest",URL] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        
//        block(responseObject,YES);
//        
//        
//        
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        
//    }];

}
+ (void)zhiFuBao:(NSDictionary *)paremeter block:(UeserInfo)block{
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_ZHIFUBAO] parameters:paremeter success:^(AFHTTPRequestOperation *operation, id responseObject)
     {
         
         block (responseObject,YES);
     } failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {
         block (nil,NO);
         
         NSLog(@"---%@",error);
         
     }];

}
+ (void)getRelease:(NSDictionary *)paremeter blcok:(UeserInfo )blcok{
    
    NSUserDefaults * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"ID"];
    
    
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    
    [manager GET:[NSString stringWithFormat:@"%@%@%@?page=1&rows=1211",URL,URL_YIFABU,userId] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        if (blcok) {
            
            blcok(responseObject,YES);
        }
    
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        if (blcok) {
            
            blcok(nil, NO);
        }
        NSLog(@"---%@",error);
        
    }];
//    [manager POST:[NSString stringWithFormat:@"%@%@%@?page=1&rows=12",URL,URL_YIFABU,userId] parameters:paremeter success:^(AFHTTPRequestOperation *operation, id responseObject)
//     {
//         
//         blcok (responseObject,YES);
//     } failure:^(AFHTTPRequestOperation *operation, NSError *error)
//     {
//         blcok (nil,NO);
//         
//         NSLog(@"---%@",error);
//         
//     }];

}
+(void)XuPeiZhuCeWanCheng:(NSString *)phoneNum pwd:(NSString *)pwd province:(NSString *)province city:(NSString *)city sex:(int)sex pic:(NSData *)pic nickName:(NSString *)nickName mac:(NSString *)DeviceID  success:(void (^)(id responseDate))success failure:(void (^) (NSString *errMessage))failure
{
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/plain",nil];
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_ZHUCE] parameters:@{@"phoneNum":phoneNum,@"pwd":pwd,@"province":province,@"city":city,@"sex":@(sex),@"nickName":nickName,@"DeviceID":DeviceID} constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
    {

        
        NSData *str = [pic base64EncodedDataWithOptions:NSDataBase64Encoding64CharacterLineLength];
        
        
//        NSData * dat  =[str dataUsingEncoding:NSUTF8StringEncoding];
        
        [formData appendPartWithFileData:str name:@"pic" fileName:@"pic.jpg" mimeType:@"image/jpeg"];
        
    } success:^(AFHTTPRequestOperation * operation, id responseObject) {
        if (success) {
            
            success (responseObject);
        }
    } failure:^(AFHTTPRequestOperation * operation, NSError * error) {
        if (failure) {
            failure ([error localizedDescription]);
        }
        
    }];
    
}
-(UIImage *)reduceImage:(UIImage *)image percent:(float)percent
{
    NSData *imageData = UIImageJPEGRepresentation(image, percent);
    UIImage *newImage = [UIImage imageWithData:imageData];
    return newImage;
}
- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize
{
    // Create a graphics image context
    UIGraphicsBeginImageContext(newSize);
    // new size
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    // Get the new image from the context
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    
    // End the context
    UIGraphicsEndImageContext();
    // Return the new image.
    return newImage;
}
+ (void)xianXiaZhiFu:(NSDictionary *)paremeter block:(UeserInfo)block{
    
    
    AFHTTPRequestOperationManager  *manager =[AFHTTPRequestOperationManager manager];
    
    [manager POST:[NSString stringWithFormat:@"%@%@",URL,URL_XIANXIA] parameters:paremeter success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        
        if (block) {
            
            block (responseObject,YES);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        if (block) {
            
            block (nil,NO);
        }
    }];
}
@end
